import java.util.ArrayList;
import java.util.List;

public class Teacher extends Person {
    private final List<Course> courses; // 所授课程列表

    // 构造方法（调用父类构造器）
    public Teacher(String teacherId, String name) {
        super(teacherId, name);
        this.courses = new ArrayList<>();
    }

    // 教师开课
    public void offerCourse(Course course) {
        if (course != null && !courses.contains(course)) {
            courses.add(course);
            course.setTeacher(this);
            System.out.println(getName() + "老师成功开设课程: " + course.getCourseName());
        }
    }

    // 重写打印方法，添加授课课程信息
    @Override
    public void printInfo() {
        super.printInfo(); // 调用父类打印基础信息
        System.out.println("身份: 教师");
        System.out.println("--- 所授课程 ---");
        if (courses.isEmpty()) {
            System.out.println("未开设任何课程");
        } else {
            for (Course course : courses) {
                System.out.println("- " + course.getCourseName() + "（" + course.getCourseId() + "）");
            }
        }
        System.out.println("----------------\n");
    }
}